using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace Pixysoft.Weblications.Sango.Battle
{

    // player property
    class BattleCharacter : ICharacter
    {

        private long totalHpPointValue = 0;
        private long leftHpPointValue = 0;

        private double attackPointValue = 0;
        private double defensePointValue = 0;
        private double skillAttackPointValue = 0;
        private double skillDefensePointValue = 0;
        private double magicAttackPointValue = 0;
        private double magicDefensePointValue = 0;

        private double criticalRateValue = 1;
        private double counterRateValue = 1;
        private double dodgePointValue = 1;
        private double hitPointValue = 1;

        public BattleCharacter()
        {
        }

        public void load(ICharacter character)
        {
            this.totalHpPointValue = character.TotalHpPointValue;
            this.leftHpPointValue = character.LeftHpPointValue;

            this.attackPointValue = character.AttackPointValue;
            this.defensePointValue = character.DefensePointValue;
            this.skillAttackPointValue = character.SkillAttackPointValue;
            this.skillDefensePointValue = character.SkillDefensePointValue;
            this.magicAttackPointValue = character.MagicAttackPointValue;
            this.magicDefensePointValue = character.MagicDefensePointValue;

            this.criticalRateValue = character.CriticalRateValue;
            this.counterRateValue = character.CounterRateValue;
            this.dodgePointValue = character.DodgePointValue;
            this.hitPointValue = character.HitPointValue;
        }


        public void addHpPointValue(long hpPointValue)
        {
            this.leftHpPointValue += hpPointValue;

            if (this.leftHpPointValue > this.totalHpPointValue)
                this.leftHpPointValue = this.totalHpPointValue;
        }

        public void reduceHpPointValue(long hpPointValue)
        {
            this.leftHpPointValue -= hpPointValue;

            if (this.leftHpPointValue <= 0)
                this.leftHpPointValue = 0;
        }


        [XmlAttribute("totalhp")]
        public long TotalHpPointValue
        {
            get { return totalHpPointValue; }
            set
            {
                this.totalHpPointValue = value;
                this.leftHpPointValue = value;
            }
        }
        [XmlAttribute("lefthp")]
        public long LeftHpPointValue
        {
            get { return leftHpPointValue; }
            set { this.leftHpPointValue = value; }
        }

        [XmlAttribute("critical")]
        public double CriticalRateValue
        {
            get { return criticalRateValue; }
            set { criticalRateValue = value; }
        }
        [XmlAttribute("counter")]
        public double CounterRateValue
        {
            get { return counterRateValue; }
            set { counterRateValue = value; }
        }
        [XmlAttribute("dodge")]
        public double DodgePointValue
        {
            get { return dodgePointValue; }
            set { dodgePointValue = value; }
        }
        [XmlAttribute("hit")]
        public double HitPointValue
        {
            get { return hitPointValue; }
            set { hitPointValue = value; }
        }

        [XmlAttribute("attack")]
        public double AttackPointValue
        {
            get { return attackPointValue; }
            set { attackPointValue = value; }
        }
        [XmlAttribute("defense")]
        public double DefensePointValue
        {
            get { return defensePointValue; }
            set { defensePointValue = value; }
        }
        [XmlAttribute("skillattack")]
        public double SkillAttackPointValue
        {
            get { return skillAttackPointValue; }
            set { skillAttackPointValue = value; }
        }
        [XmlAttribute("skilldefense")]
        public double SkillDefensePointValue
        {
            get { return skillDefensePointValue; }
            set { skillDefensePointValue = value; }
        }
        [XmlAttribute("magicattack")]
        public double MagicAttackPointValue
        {
            get { return magicAttackPointValue; }
            set { magicAttackPointValue = value; }
        }
        [XmlAttribute("magicdefense")]
        public double MagicDefensePointValue
        {
            get { return magicDefensePointValue; }
            set { magicDefensePointValue = value; }
        }

    }
}